<?php 
require_once dirname(__FILE__) . '/../includes/common.inc.php';
require_once dirname(__FILE__) . '/../includes/pdoorm.inc.php';

    /*if(!isset($_COOKIE['pwd']) || empty($_COOKIE['pwd']))
    {
        header("Location: index.php"); 
        exit;
    }*/

//echo $_SESSION['pwd'];
    
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>IPAD SIGN HOME</title>
  <style>
  body{
   margin:0px;
   font-family:Arial;
   font-size:13px;
   
   background:#d9d6cd;
  }
  img{
   border:0px;
  }
  .bgff{background:#ffffff;}
  .baise{
   color:#ffffff;
  }
  .fr{
    float:right;
  }
  .fl{
    float:left;
  }
  .bck{
    margin-top:-7px;
    margin-left:50px;
  }
  .mr50{
    margin-right:50px;
  }
  .input-text{
    height:40px;
    font-weight:bold;
    font-size:22px;
    margin-left:15px;
  }
  .goimg{
    margin-bottom:-20px;
    margin-left:10px;
  }
  .mt{
    margin-top:30px;
  }
  .ml30{margin-left:30px;}
  .txt_default{
    position:absolute;
    font-size:16px;
    font-family:"Microsoft Yahei",Tahoma;
    color:#b3b3b3;
    top:47px;
    left:30px;
    cursor:text;
  }
  .h40{
   height:40px;
  }
  .cusno
  {
    font-size:22px;
    margin-left:30px;
    color:#674541;
    font-weight:bold;
  }
  .cno{
    font-size:22px;
    text-align:center;
    background:#f5ebe1;
    color:#000000;
    font-weight:bold;
  }
  .otitle{
    font-size:22px;
    margin-left:30px;
    color:#674541;
    font-weight:bold;    
    padding-left:30px;
    height:60px;
  }
  .divcenter{margin-left:auto;margin-right:auto;}
  .heise{color:#000000;}
  .hongse{color:red;}
  .huise{color:#4F4F4F;}
  .fb{font-weight:bold;}
  .arrow{padding-left:10px;}
  .bbottom{border-bottom:2px solid #EAEAEA;}
  .yj{-moz-border-radius: 8px;border-radius: 8px;}
  
  </style>
  <script type="text/javascript" src="../jquery-1.7.1.min.js"></script>
  <script type="text/javascript">
  $(function(){
	  
  	  var piback = parent. document.getElementById('iback');
	  piback.src = 'images/home/nav-back-2.png';
      piback.onclick=function(){};
	  
	  var customerno = '<?php echo $_REQUEST['customerid'];?>';

		  if(customerno != '')
		  {
			  $("#cno").val(customerno);
			  $('#uhint').hide();
			  
				  $.ajax({
						type:'POST',
						url:'server.php',
						data:"customerid="+ customerno +"&action=customerquery",
						dataType: "json",
						beforeSend:function(){
		                //$("#queryid").append("<img src='../images/common/loading.gif'>");
			            },						
						success:function(data){
							 showdata(data.data[0]);
			
							}		
						}); 
		  }
	  });
  
    function query_no()
    {
        var customerno = $("#cno").val();
  	  $.ajax({
			type:'POST',
			url:'server.php',
			data:"customerid="+ customerno +"&action=customerquery",
			dataType: "json",
			beforeSend:function(){
                //$("#queryid").append("<img src='../images/common/loading.gif'>");
	        },
			success:function(data){
  		        showdata(data.data[0]);
			   }		
			}); 
        
    }

    function showdata(data)
    {
	  
 		 if(data != '')
 		 {
 			 $('#queryid').css("display",""); 
 			$('#customerno').html("");
 			$('#typelist').html("");

 			 document.getElementById('customerno').appendChild(document.createTextNode('<?php echo BRANCH;?>' + MiscUtils.customerId(data.customerid)));


 			 for(var i = 0 , j = data.orders.length;i < j; i++)
 			 {
                 var o = data.orders[i];
                 if(o.disposalstatus == 1) continue;
                 
                 var signlen = o.sign.length;
                 
 			    tr = document.getElementById('typelist').insertRow(-1);//行
 			    tr.style.cursor = 'pointer';
 			    tr._order = o;
 			    tr.onclick = function(){
 			    	window.location.href='contract.php?orderid='+this._order.e_oid;

 	 			  }

 		        td = tr.insertCell(-1);
 		        if(i == j-1)
 		        {
 		        	td.className = 'otitle baise';
 	 		    }else{
 	 		    	td.className = 'otitle baise bbottom';
 	 	 		}
 	 	 		
 		        
 		        td.appendChild(document.createTextNode(o.type));

 		        td = tr.insertCell(-1);
 		        if(i == j-1)
 		        {
 	 		        if( signlen== 0)
 	 		        {
 	 		        	td.className = 'hongse fb';
 	 		        	td.style.fontSize = '140%';
 	 		        	var stitle = 'Unsigned';
 	 	 		    }else{
 		        	    td.className = 'huise fb';
 		        	    td.style.fontSize = '140%';
 		        	   var stitle = 'Signed';
 	 	 		    }
 	 	 		    
 	 		    }else{
 	 		        if( signlen== 0)
 	 		        {
 	 		        	td.className = 'hongse fb bbottom';
 	 		        	td.style.fontSize = '140%';
 	 		        	var stitle = 'Unsigned';
 	 	 		    }else{
 	 	 		    	td.className = 'huise fb bbottom';
 	 	 		    	td.style.fontSize = '140%';
 	 	 		    	var stitle = 'Signed';
 	 	 		    }
 	 	 		    
 	 		    	
 	 	 		}
 		        
 		        
 		        td.style.textAlign = 'right';
 		        td.appendChild(document.createTextNode(stitle));

 		        td = tr.insertCell(-1);
 		        if(i == j-1)
 		        {
 		           td.className = 'uise arrow';
 		        }else{
 	 		       
 		        	td.className = 'uise arrow bbottom';
 	 		    }
 	 		    
 		        td.style.textAlign = 'left';

                 var img = document.createElement('img');
                     img.src = "images/home/arrow.png";
 		        
 		        td.appendChild(img);       
 			}
 		}	   
    }


   
   function SimpleDate() {
   };

   SimpleDate.create = function(year, month, date, hours, minutes, seconds) {
  	  if (!arguments.length) {
  	    return this.fromDate(new Date(), false);
  	  }
  	  return { year: (year != null) ? year : 0,
  	           month: (month != null) ? month : 0,
  	           date: (date != null) ? date : 0,
  	           hours: (hours != null) ? hours : 0,
  	           minutes: (minutes != null) ? minutes : 0,
  	           seconds: (seconds != null) ? seconds : 0
  	         };
  	};

  	SimpleDate.fromDate = function(d, hasTime) {
  	  if (!d) {
  	    return this.create(0, 0, 0);
  	  }
  	  if (hasTime) {
  	    return this.create(d.getFullYear(), d.getMonth() + 1, d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds());
  	  } else {
  	    return this.create(d.getFullYear(), d.getMonth() + 1, d.getDate());
  	  }
  	};

  	SimpleDate.fromStamp = function(stamp, hasTime) {
  	  return this.fromDate(new Date(stamp * 1000), hasTime);
  	};

  	SimpleDate.toDate = function(sd) {
  	  if (!sd) {
  	    return null;
  	  }
  	  return new Date(sd.year, sd.month - 1, sd.date, sd.hours, sd.minutes, sd.seconds);
  	};

  	SimpleDate.toStamp = function(sd) {
  	  if (!sd) {
  	    return null;
  	  }
  	  var d = this.toDate(sd);
  	  return (d) ? (d.getTime() / 1000) : 0;
  	};

  	SimpleDate.clone = function(sd) {
  	  if (!sd) {
  	    return null;
  	  }
  	  return SimpleDate.create(sd.year, sd.month, sd.date, sd.hours, sd.minutes, sd.seconds);
  	};

  	SimpleDate.fmtDigits = function(num) {
  	  num = parseInt(num, 10);
  	  return (num < 10) ? ('0' + num) : num;
  	};

  	SimpleDate.forward = function(sd, stamp) {
  	  return this.fromStamp(this.toStamp(sd) + stamp, true);
  	};

  	SimpleDate.backward = function(sd, stamp) {
  	  return this.fromStamp(this.toStamp(sd) - stamp, true);
  	}; 
   
   /*SimpleDate.fmtDigits = function(num) {
  	  num = parseInt(num, 10);
  	  return (num < 10) ? ('0' + num) : num;
  	};*/
  	
  	SimpleDate.format = function(sd, showTime) {
  		  if (!sd) {
  		    return 'Unknown';
  		  }
  		  if (!showTime) {
  		    return SimpleDate.fmtDigits(sd.date) + '/' + SimpleDate.fmtDigits(sd.month) + '/' + sd.year;
  		  }
  		  return SimpleDate.fmtDigits(sd.hours) + ':' + SimpleDate.fmtDigits(sd.minutes) + ',' + SimpleDate.fmtDigits(sd.date) + '/' + SimpleDate.fmtDigits(sd.month) + '/' + sd.year;
  		};

  		function MiscUtils() {
  		};

  		MiscUtils.span = function(content) {
  			  span = document.createElement('span');
  			  var str = '';
  			  for (var i = 0, il = content.length; i < il; i++) {
  			    if (content.charAt(i) != '\n') {
  			      str += content.charAt(i);
  			    } else {
  			      span.appendChild(document.createTextNode(str));
  			      span.appendChild(document.createElement('br'));
  			      str = '';
  			    }
  			  }
  			  span.appendChild(document.createTextNode(str));
  			  return span
  			};
  			MiscUtils.customerId = function(customerId) {
  				  if (customerId < 100000 && customerId >= 10000) {
  				    customerId = customerId;
  				  } else if (customerId < 10000 && customerId >= 1000) {
  				    customerId = '0' + customerId;
  				  } else if (customerId < 1000 && customerId >= 100) {
  				    customerId = '00' + customerId;
  				  } if (customerId < 100 && customerId >= 10) {
  				    customerId = '000' + customerId;
  				  } if (customerId < 10 && customerId > 0) {
  				    customerId = '0000' + customerId;
  				  }
  				  return customerId;
  				};   
  </script>
 </head>

 <body >
 <div class="baise mt divcenter" >
 <table width="90%" border=0>
   <tr>
      <td>
      <label id="uhint" for="cno" class="txt_default">Customer No.</label>
      <input type="text" id='cno' class='input-text' onfocus="$('#uhint').hide();" onblur="if($('#cno').val()=='')$('#uhint').show();" style="width:270px;" value=''>
      <img  class="goimg" src="images/home/go.png" onclick="query_no();"></td>
   </tr>
 </table>
 </div>
  <div class="baise mt divcenter" id="queryid" style="display:none">
 <table width="100%" align="center" border=0>
   <tr>
      <td class="h40" >
      <span class="cusno" style="margin-left:15px;">Customer No.</span>&nbsp;&nbsp;<span class="cno">&nbsp;&nbsp;&nbsp;&nbsp;<label id='customerno'></label>&nbsp;&nbsp;&nbsp;&nbsp;</span>
      </td>
   </tr>
   <tr>
      <td class="h40">
        <div style="margin-left:15px;margin-right:15px;">
        <table width="100%"  class="bgff yj"   border=0  cellPadding="0" cellSpacing="0">
        <tbody id = 'typelist'>
        
        </tbody>
         <!--  <tr onclick="javascript:window.location.href='contract.php'" style="cursor:pointer">
             <td class="otitle baise bbottom">Wedding</td>
             <td class="huise fb bbottom" align="right">Signed</td>
             <td class="huise arrow bbottom" align="left"><img src="images/home/arrow.png"></td>
          </tr>
          <tr  onclick="javascript:window.location.href='contract.php'" style="cursor:pointer">
             <td class="otitle baise bbottom">Engagement</td>
             <td class="hongse fb bbottom" align="right">Unsigned</td>
             <td class="huise arrow bbottom" align="left"><img src="images/home/arrow.png"></td>
          </tr>
          <tr onclick="javascript:window.location.href='contract.php'" style="cursor:pointer">
             <td class="otitle baise">Prewedding</td>
             <td class="huise fb" align="right">Signed</td>
             <td class="huise arrow" align="left"><img src="images/home/arrow.png"></td>
          </tr> -->          
        </table>
        </div>
      </td>
   </tr>
 </table>
 </div>
 </body>
</html>